Saves any changes in the session that have occurred since the session was created or the session was previously committed. You must call this method before disposing the session to ensure session changes to the session are persisted to LearningStore.
Parent Type: StoredLearningSession
Namespace: Microsoft.LearningComponents.Storage
Assembly: Microsoft.LearningComponents.Storage.dll
| C# |
|
public override void CommitChanges () |
| Exception type | Condition |
| InvalidOperationException | Thrown if the state of the session and / or its associated data model are in an inconsistent state. For instance, if a stream provided as an attachment to the data model exceeds the size allowed by the MaxExtensionDataSize of this session, this exception will be thrown. |
Applications should always call this function after exiting the session or performing any operation that changes the state of the session, such as MoveNext(), MovePrevious() or setting any values in the CurrentActivityDataModel.
This method commits session changes to LearningStore. As such, it is a relatively slow operation. Therefore, it is recommended that applications use this StoredLearningSession object to modify as much as possible before calling CommitChanges. At that point, all previous changes will be saved. For example:
| C# |
LearningStore learningStore; // this should be properly initialized
FileSystemPackageStore packageStore; // this should be properly initialized
PackageItemIdentifier packageId; // this should be properly initialized
// Load an existing session.
StoredLearningSession session = new StoredLearningSession( learningStore, SessionView.Execute, attemptId, packageStore);
if (session.AttemptStatus == AttemptStatus.Suspended)
{
session.Resume();
}
// Change a data model element
session.CurrentActivityDataModel.Score.Raw = 95;
// Navigate to the next activity in the session
session.MoveToNext();
// Save all previous changes
session.CommitChanges();
|
If there have been no changes to the session, this method has no effect.
It is not valid to call this method in Review view.
In RandomAccess view, data model changes are saved, but the results of navigation changes are not. In that case, subsequent instantiations of the StoredLearningSession will reload the attempt data without showing the effect of navigations performed in RandomAccess view.